<template>
  <div class="backjs">
    <div class="dialog">
      <header>
        <span>编辑秒杀商品</span>
        <svg-icon
          icon-class="x"
          @click="onSubmit"
        />
      </header>
      <main>
        <el-form
          ref="form"
          :model="form"
          label-width="100px"
        >
          <el-form-item label="图片:">
            <template>
              <img :src="form.address">
            </template>
          </el-form-item>
          <el-form-item label="ID:">
            <el-input v-model="form.id" />
          </el-form-item>
          <el-form-item label="配置">
            <el-input v-model="form.deploy" />
          </el-form-item>
          <el-form-item label="时段:">
            <el-input v-model="form.period" />
          </el-form-item>
          <el-form-item label="标题:">
            <el-input v-model="form.title" />
          </el-form-item>
          <el-form-item label="简介:">
            <el-input v-model="form.intro" />
          </el-form-item>
          <el-form-item label="原价:">
            <el-input v-model="form.cost" />
          </el-form-item>
          <el-form-item label="秒杀价:">
            <el-input v-model="form.spike" />
          </el-form-item>
          <el-form-item label="限量:">
            <el-input v-model="form.limit" />
          </el-form-item>
          <el-form-item label="限量剩余:">
            <el-input v-model="form.residue" />
          </el-form-item>
          <el-form-item label="创建时间:">
            <el-input v-model="form.date" />
          </el-form-item>
          <el-form-item label="状态：">
            <template>
              <el-switch
                :value="form.status === 1"
                active-color="#1890ff"
                inactive-color="#dcdfe6"
                @input="setStatus($event, from.status)"
              />
            </template>
          </el-form-item>
          <el-form-item class="buttonss">
            <el-button
              type="primary"
              @click="onSubmit"
            >
              确定
            </el-button>
            <el-button @click="onSubmit">
              取消
            </el-button>
          </el-form-item>
        </el-form>
      </main>
    </div>
  </div>
</template>

<script>
export default {
  // eslint-disable-next-line vue/require-prop-types
  props: ["scops"],
  data() {
    return {
      dialogImageUrl: "",
      dialogVisible: false,
      value: "",
      form: {
        address: "",
        date: "",
        status: 0,
        id: 0,
        period: "",
        deploy: "",
        intro: "",
        limit: 0,
        residue: 0,
        spike: 0,
        title: "",
        cost: 0
      }
    };
  },

  created() {
    this.form = this.scops;
  },
  methods: {
    setStatus(status, row) {
      setTimeout(() => {
        row.status = status ? 1 : 0;
      }, 500);
    },
    onSubmit() {
      this.$emit("isShowPile", false);
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    }
  }
};
</script>

<style lang="scss" scoped>
.backjs {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  background: rgba(0, 0, 0, 0.2);
  .dialog {
    width: 800px;
    height: auto;
    background: #fff;
    z-index: 9999;
    // margin-top: 100px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -40%);
    padding: 10px;
    box-shadow: 0 0 12px 6px #9d9b9b;
    display: flex;
    flex-direction: column;

    header {
      width: 100%;
      height: 50px;
      border-bottom: 1px solid #f6f7f8;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 15px;
      margin-bottom: 20px;
      span {
        color: #c2c4c7;
        font-weight: bold;
        font-size: 16px;
      }
    }
    main {
      display: flex;
      .el-form {
        width: 100%;
        height: 100%;
        display: flex;
        flex-wrap: wrap;
        .el-form-item__content {
          margin-left: 50px;
        }
        .el-form-item {
          width: 50%;
          padding-right: 40px;
        }
        .buttonss {
          text-align: center;
          button {
            margin: 0 20px;
          }
        }
        .el-form-item.buttonss {
          width: 100%;
        }
      }
    }
  }
}
</style>
